﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Powershell_ML
{
    class Logger
    {
        public static System.Diagnostics.EventLog Application = new System.Diagnostics.EventLog("Application");
        public Logger(string Code_Part_Source)
        {
            this.Code_Block = Code_Part_Source ?? "Unknow";
            this.Logger_Start_Time = DateTime.Now;

        }

        public void Add_Entry(string CodeBlock, int RetryCount, bool autocorrected, int customcode, DateTime Event_Date, string Event_Source, bool info)
        {
            try
            {
                Application.Source = "Application";
                Application.WriteEntry(
                    "Entry Requested by Main Thread " + Environment.NewLine +
                    "Block : " + CodeBlock + Environment.NewLine +
                    "Retry Count : " + RetryCount.ToString() + Environment.NewLine +
                    "AutoCorrected :" + autocorrected.ToString() + Environment.NewLine +
                    "Event Date " + Event_Date.ToLongDateString() + Environment.NewLine +
                    "Informative : " + info.ToString() + Environment.NewLine
                    , System.Diagnostics.EventLogEntryType.Information, 1018);

            }
            catch { }
        }

        public DateTime Logger_Start_Time
        {
            get; set;
        }
        public int Custom_App_Code
        {
            get; set;
        }
        public int Retry_Number
        {
            get;
            set;
        }
        public bool AutoCorrected_Exception
        {
            get; set;
        }
        public string Code_Block
        {
            get; set;
        }
        public string Exception
        {
            get;
            set;
        }
        public DateTime Correct_Event
        {
            get;
            set;
        }
        public DateTime Start_Event
        {
            get;
            set;
        }
        public string Event_Source
        {
            get; set;
        }
    }
}
